package java_class_work.week04.practice01;

import java.util.Scanner;

/**
 * @Auther: admin
 * @Date: 2022/10/4 10:34
 * @Description:
 */

public class Login {
    public static final int COUNT = 3;

    public static void main(String[] args) {
        User userDB = new User("admin", "123456");
        int count = 0;
        Scanner scanner = new Scanner(System.in);
        do {
            System.out.print("请输入用户名:");
            String username = scanner.next();
            System.out.print("请输入密码:");
            String password = scanner.next();
            User user = new User(username, password);
            if (!user.equals(userDB)) {
                System.out.println("账号或密码错误！");
                count++;
            } else {
                break;
            }
            if (count == COUNT) try {
                throw new OverTimeException("超过最大次数！");
            } catch (OverTimeException e) {
                e.printStackTrace();
                return;
            }
        } while (true);
        System.out.println("登录成功！");
    }
}
